package ProjectTeam39.GUITest;

import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JSplitPane;
import javax.swing.SwingConstants;
import javax.swing.JRadioButton;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JTextField;

import ProjectTeam39.Domains.UserList;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class EditUserFrame extends JFrame {
	private final ButtonGroup buttonGroup = new ButtonGroup();
	private JTextField textField;
	private JTextField textField_1;
	int buttonPressed;
	UserList ul;
	EditUserFrame EUFrame = this;
	
	public EditUserFrame(final UserList ul) {
		this.ul = ul;
		JPanel panel = new JPanel();
		getContentPane().add(panel, BorderLayout.NORTH);
		
		JSplitPane splitPane = new JSplitPane();
		splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
		panel.add(splitPane);
		
		JLabel lblEditUsers = new JLabel("Edit Users");
		lblEditUsers.setHorizontalAlignment(SwingConstants.CENTER);
		splitPane.setLeftComponent(lblEditUsers);
		lblEditUsers.setFont(new Font("Tahoma", Font.PLAIN, 14));
		
		JSplitPane splitPane_1 = new JSplitPane();
		splitPane.setRightComponent(splitPane_1);
		
		JSplitPane splitPane_2 = new JSplitPane();
		splitPane_2.setOrientation(JSplitPane.VERTICAL_SPLIT);
		splitPane_1.setLeftComponent(splitPane_2);
		
		JSplitPane splitPane_4 = new JSplitPane();
		splitPane_2.setLeftComponent(splitPane_4);
		
		JRadioButton rdbtnCreateNurse = new JRadioButton("Create Nurse");
		rdbtnCreateNurse.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				buttonPressed = 0;
				textField.setEnabled(true);
				textField_1.setEnabled(true);
			}
		});
		buttonGroup.add(rdbtnCreateNurse);
		splitPane_4.setLeftComponent(rdbtnCreateNurse);
		
		JRadioButton rdbtnCreateDoctor = new JRadioButton("Create Doctor");
		rdbtnCreateDoctor.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				buttonPressed = 0;
				textField.setEnabled(true);
				textField_1.setEnabled(true);
			}
		});
		buttonGroup.add(rdbtnCreateDoctor);
		splitPane_4.setRightComponent(rdbtnCreateDoctor);
		
		JSplitPane splitPane_7 = new JSplitPane();
		splitPane_2.setRightComponent(splitPane_7);
		
		JRadioButton rdbtnDeleteNurse = new JRadioButton("Delete Nurse");
		rdbtnDeleteNurse.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				buttonPressed = 0;
				textField.setEnabled(true);
				textField_1.setEnabled(false);
			}
		});
		buttonGroup.add(rdbtnDeleteNurse);
		splitPane_7.setLeftComponent(rdbtnDeleteNurse);
		
		JRadioButton rdbtnDeleteDoctor = new JRadioButton("Delete Doctor");
		rdbtnDeleteDoctor.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				buttonPressed = 0;
				textField.setEnabled(true);
				textField_1.setEnabled(false);
			}
		});
		buttonGroup.add(rdbtnDeleteDoctor);
		splitPane_7.setRightComponent(rdbtnDeleteDoctor);
		
		JSplitPane splitPane_3 = new JSplitPane();
		splitPane_3.setOrientation(JSplitPane.VERTICAL_SPLIT);
		splitPane_1.setRightComponent(splitPane_3);
		
		JSplitPane splitPane_5 = new JSplitPane();
		splitPane_3.setLeftComponent(splitPane_5);
		
		JRadioButton rdbtnSuspendUser = new JRadioButton("Suspend User");
		rdbtnSuspendUser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				buttonPressed = 0;
				textField.setEnabled(true);
				textField_1.setEnabled(false);
			}
		});
		buttonGroup.add(rdbtnSuspendUser);
		splitPane_5.setLeftComponent(rdbtnSuspendUser);
		
		JRadioButton rdbtnUnsuspendUser = new JRadioButton("Unsuspend User");
		rdbtnUnsuspendUser.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				buttonPressed = 0;
				textField.setEnabled(true);
				textField_1.setEnabled(false);
			}
		});
		buttonGroup.add(rdbtnUnsuspendUser);
		splitPane_5.setRightComponent(rdbtnUnsuspendUser);
		
		JSplitPane splitPane_6 = new JSplitPane();
		splitPane_3.setRightComponent(splitPane_6);
		
		JRadioButton rdbtnSetPassword = new JRadioButton("Set Password");
		rdbtnSetPassword.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				buttonPressed = 0;
				textField.setEnabled(true);
				textField_1.setEnabled(true);
			}
		});
		buttonGroup.add(rdbtnSetPassword);
		splitPane_6.setLeftComponent(rdbtnSetPassword);
		
		JRadioButton rdbtnResetPassword = new JRadioButton("Reset Password");
		rdbtnResetPassword.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				buttonPressed = 0;
				textField.setEnabled(true);
				textField_1.setEnabled(true);
			}
		});
		buttonGroup.add(rdbtnResetPassword);
		splitPane_6.setRightComponent(rdbtnResetPassword);
		
		JPanel panel_1 = new JPanel();
		getContentPane().add(panel_1, BorderLayout.SOUTH);
		
		JSplitPane splitPane_8 = new JSplitPane();
		panel_1.add(splitPane_8);
		
		JButton btnSubmit = new JButton("Submit");
		splitPane_8.setLeftComponent(btnSubmit);
		
		JButton btnCancel = new JButton("Cancel");
		btnCancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				AdminFrame aframe = new AdminFrame(ul);
				EUFrame.setVisible(false);
				aframe.setBounds(100, 100, 450, 300);
				aframe.setVisible(true);
				aframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			}
		});
		splitPane_8.setRightComponent(btnCancel);
		
		JPanel panel_2 = new JPanel();
		getContentPane().add(panel_2, BorderLayout.CENTER);
		
		JLabel lblUsername = new JLabel("Username");
		panel_2.add(lblUsername);
		
		textField = new JTextField();
		panel_2.add(textField);
		textField.setColumns(10);
		
		JLabel lblPassword = new JLabel("Password");
		panel_2.add(lblPassword);
		
		textField_1 = new JTextField();
		panel_2.add(textField_1);
		textField_1.setColumns(10);
	}
	
}
